This informs the compiler to prepared for an input operation that might fail.
Say that you want to write a program that calculates the total bill
for a restaurant meal.
The input to the program will be the basic cost of the meal.
To this is added 6% sales tax and a 20% tip on the before-tax cost.
Arithmetic will be done with type double.
Here is the program, with some parts left out:
import java.io.*;
class RestaurantBill
{
public static void main (String[] args) _______________________
{
String charData;
double basicCost;
_____________________________________
_____________________________________
_____________________________________
_____________________________________
System.out.println("basic cost: " +
basicCost + " total cost: "
+ _____________________________ );
}
}
These are the missing parts, but not in order:
(basicCost + basicCost*0.06 + basicCost*0.20)
System.out.println("Enter the basic cost:");
basicCost = Double.parseDouble( charData ) ;
BufferedReader stdin
= new BufferedReader(
new InputStreamReader( System.in ) );
charData = stdin.readLine();
throws IOException